home *** CD-ROM | disk | FTP | other *** search
Java Source | 2000-09-01 | 5.1 KB | 171 lines |
- /**
- Company: Eyematic Interfaces
- Project: Shout3D 2.0 Sample Code
- Class: ExaminePanel
- Date: April 3, 2000
- Description: Class for ExaminePanel
- (C) Copyright Eyematic Interfaces, Inc. - 1997/1998/1999/2000 - All rights reserved
- */
-
- package applets;
-
- import java.applet.*;
- import java.awt.*;
- import shout3d.core.*;
- import shout3d.*;
-
- import custom_nodes.*;
-
- /**
- * A SelectAPanoramaPanel.
- *
- * @author Dave Westwood
- * @author Paul Isaacs
- * @author Jim Stewartson
- */
-
- public class SelectAPanoramaPanel extends ExaminePanel implements DeviceObserver {
-
-
- Panorama panorama;
- EnvironmentCubeMap envCubeMap;
- MultiMesh[] meshes;
-
- /**
- * Constructs me
- */
- public SelectAPanoramaPanel(Shout3DApplet applet){
- super(applet);
- }
- /**
- * Constructs me
- */
- public SelectAPanoramaPanel(Shout3DApplet applet, int width, int height){
- super(applet,width, height);
- }
-
- /**
- * Remove observers when done with the panel
- */
- public void finalize()throws Throwable {
- applet.getDeviceListener().removeDeviceObserver(this, "DeviceInput");
- applet.getRenderer().removeRenderObserver(this);
- super.finalize();
- }
-
- /**
- * Overrides Shout3DPanel.customInitialize()
- */
- public void customInitialize() {
- super.customInitialize();
-
- // register for device input
- applet.getDeviceListener().addDeviceObserver(this, "DeviceInput", null);
- // register for rendering notification
- applet.getRenderer().addRenderObserver(this, null);
-
- Searcher mySearcher = getNewSearcher();
-
- // reference to Panorama
- mySearcher.setType("Panorama");
- Node[] path = mySearcher.searchFirst(getScene());
- if (path!=null && path.length>0){
- panorama = (Panorama)path[path.length-1];
- }
-
- // reference to EnvironmentCubeMap used in a Panorama
- mySearcher.setType("EnvironmentCubeMap");
- path = mySearcher.searchFirst(getScene());
- if (path!=null && path.length>0){
- envCubeMap = (EnvironmentCubeMap)path[path.length-1];
- }
-
- // reference to env mapped meshes
- mySearcher.setType("MultiMesh");
- Node[][] paths = mySearcher.searchAll(getScene());
- if (paths!=null && paths.length>0){
- meshes = new MultiMesh[paths.length];
- for (int i = 0; i < paths.length; i++){
- meshes[i] = (MultiMesh)paths[i][paths[i].length-1];
- }
- }
-
- // Turn off antialiasing so that the env map will change even if
- // camera is still
- mySearcher.setType("StillCamProgAntialias");
- path = mySearcher.searchFirst(getScene());
- if (path!=null && path.length>0){
- StillCamProgAntialias aa = (StillCamProgAntialias)path[path.length-1];
- aa.enabled.setValue(false);
- }
-
- }
-
- public boolean onDeviceInput(DeviceInput di, Object userData){
- return super.onDeviceInput(di, userData);
- }
- ImageTexture itex;
-
- /**
- * Set the EnvironmentCubeMap textures and/or change bilinear filtering
- * if we are waiting to do so.
- *
- * Note that no onPreRender() method is implemented in this class,
- * even though it is required for all classes implementing RenderObserver.
- * This is because the super class implements RenderObserver fully
- * and onPreRender is inherited.
- * Hence this class needs only to override the onPostRender() method,
- * making sure to call super.onPostRender(r,userData) within the body
- * of the method.
- */
- public void onPostRender(Renderer r, Object userData){
- super.onPostRender(r, userData);
- if (envCubeMap!= null && set_envmap_urls){
- itex = (ImageTexture) envCubeMap.frontTexture.getValue();
- if (itex != null)
- itex.url.setValue(new String[]{frontmap});
- itex = (ImageTexture) envCubeMap.rightTexture.getValue();
- if (itex != null)
- itex.url.setValue(new String[]{rightmap});
- itex = (ImageTexture) envCubeMap.backTexture.getValue();
- if (itex != null)
- itex.url.setValue(new String[]{backmap});
- itex = (ImageTexture) envCubeMap.leftTexture.getValue();
- if (itex != null)
- itex.url.setValue(new String[]{leftmap});
- itex = (ImageTexture) envCubeMap.upTexture.getValue();
- if (itex != null)
- itex.url.setValue(new String[]{upmap});
- itex = (ImageTexture) envCubeMap.downTexture.getValue();
- if (itex != null)
- itex.url.setValue(new String[]{downmap});
- set_envmap_urls = false;
- }
- if (envCubeMap != null && set_bilerp_enabled){
- envCubeMap.bilinearFilteringEnabled.setValue(bilerp_enabled);
- panorama.bilinearFilteringEnabled.setValue(bilerp_enabled);
- set_bilerp_enabled = false;
- }
- }
-
- boolean set_envmap_urls = false;
- String frontmap, rightmap, backmap, leftmap, upmap, downmap;
- public void setEnvMaps(String _frontmap, String _rightmap, String _backmap, String _leftmap,
- String _upmap, String _downmap){
- frontmap = _frontmap;
- rightmap = _rightmap;
- backmap = _backmap;
- leftmap = _leftmap;
- upmap = _upmap;
- downmap = _downmap;
- set_envmap_urls = true;
- }
-
- boolean set_bilerp_enabled = false;
- boolean bilerp_enabled = true;
- public void setBilerpEnabled(boolean _bilerp_enabled){
- set_bilerp_enabled = true;
- bilerp_enabled = _bilerp_enabled;
- }
- }
-